package com.maikang.exammall.entity;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.SuperBuilder;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import java.util.Date;

@SuperBuilder
@MappedSuperclass
@DynamicInsert
@DynamicUpdate
@NoArgsConstructor
@AllArgsConstructor
@Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper=true)
@JsonIgnoreProperties(ignoreUnknown = true)
//@EntityListeners(AuditingEntityListener.class)
abstract public class AuditEntity<PRIMARY_KEY> extends BaseEntity<PRIMARY_KEY> {
//    @ApiModelProperty(hidden = true)
//    @CreatedBy
//    protected Long createdBy;
//
    @ApiModelProperty(hidden = true)
//    @CreatedDate
    @CreationTimestamp
    @Column(name = "create_time", updatable = false)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    protected Date createdDate;
//
//    @ApiModelProperty(hidden = true)
//    @LastModifiedBy
//    protected String lastModifiedBy;

    @ApiModelProperty(hidden = true)
//    @LastModifiedDate
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @UpdateTimestamp
    @Column(name = "update_time")
    protected Date lastModifiedDate;

    @ApiModelProperty(hidden = true)
    @JsonIgnore
    protected int isDeleted;

}
